package com.mckillion.Exercise12;

import java.util.ArrayList;
import java.util.Iterator;

public class CompositeLandBehaviour implements LandBehaviour {

	@SuppressWarnings("rawtypes")
	private ArrayList landList;
	
	@SuppressWarnings("rawtypes")
	public CompositeLandBehaviour(){
		landList = new ArrayList();
	}
	
	@SuppressWarnings("unchecked")
	public void addBehaviour(LandBehaviour lb){
		landList.add(lb);
	}
	
	@Override
	public void drive() {
		@SuppressWarnings("unchecked")
		Iterator <LandBehaviour> iterator = landList.iterator();
		while(iterator.hasNext()){
			LandBehaviour lb = (LandBehaviour) iterator.next();
			lb.drive();
		}
	}
}